<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="new :: common_head('策略生成')"></head>

<body>
<!-- start: Header -->
<div th:replace="~{new::header}"></div>
<!-- end: Header -->

<div class="container-fluid-full">
    <div class="row-fluid">

        <!-- start: Main Menu -->
        <div id="sidebar-left" class="span2" th:replace="new::sidebar_left"></div>
        <!-- end: Main Menu -->

        <noscript>
            <div class="alert alert-block span10">
                <h4 class="alert-heading">Warning!</h4>
                <p>You need to have <a href="" target="_blank">JavaScript</a> enabled to use this site.</p>
            </div>
        </noscript>

        <!-- start: Content -->
        <div id="content" class="span10">
            <ul class="breadcrumb">
                <li>
                    <i class="fas fa-circle-notch"></i>
                    <a th:href="@{/graphInfo/viewGraphInfo}">Home</a>
                    <i class="icon-angle-right"></i>
                </li>
                <li><a href="#">[[${deviceName}]]策略生成</a></li>
            </ul>

            <div class="row-fluid sortable">
                <div class="box span12">
                    <div class="box-header" data-original-title>
                        <h2><i class="halflings-icon white edit"></i><span class="break"></span>[[${deviceName}]]</h2>
                        <div class="box-icon">
                            <a href="#" class="btn-setting"><i class="halflings-icon white wrench"></i></a>
                            <a href="#" class="btn-minimize"><i class="halflings-icon white chevron-up"></i></a>
                            <a href="#" class="btn-close"><i class="halflings-icon white remove"></i></a>
                        </div>
                    </div>
                    <div class="box-content" style="position:relative">
                        <form class="form-horizontal">
                            <div class="control-group">
                                <form method="POST" enctype="multipart/form-data" action="/multipower/upload">
                                    <fieldset>
                                        <legend>用能设备历史数据上传(用于训练模型)：</legend>
                                        文件：<input type="file" name="file" id="file"/><br/>

                                        <input type="button" id="upload" value="上传"/><br/>
                                    </fieldset>
                                </form>

                                <form method="get" enctype="multipart/form-data" action="/multipower/gen">
                                    <button id="btn-submit">策略生成</button>
                                </form>
                            </div>
                        </form>
                    </div>
                </div><!--/span-->
            </div><!--/row-->
        </div>
    </div>
</div>

<div class="modal hide fade" id="myModal">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h3>Settings</h3>
    </div>
    <div class="modal-body">
        <p>Here settings can be configured...</p>
    </div>
    <div class="modal-footer">
        <a href="#" class="btn" data-dismiss="modal">Close</a>
        <a href="#" class="btn btn-primary">Save changes</a>
    </div>
</div>
<div class="common-modal modal fade" id="common-Modal1" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-content">
        <ul class="list-inline item-details">
            <li><a href="http://sc.chinaz.com">Admin templates</a></li>
            <li><a href="http://sc.chinaz.com">Bootstrap themes</a></li>
        </ul>
    </div>
</div>
<div class="clearfix"></div>

<div th:replace="new::common_js"></div>

<script th:src="@{/js/detect-element-resize.js}"></script>
<script th:src="@{/js/iframe-resize.js}"></script>

<!--<script th:src="@{/js/jquery-1.9.1.min.js}"></script>-->

<script>
    $(function () {
        $("#upload").click(function () {
            var formData = new FormData();
            formData.append("file", document.getElementById("file").files[0]);
            $.ajax({
                url: "/multipower/upload",
                type: "POST",
                data: formData,

                //必须false才会自动加上正确的Content-Type
                contentType: false,

                //必须false才会避开jquery对 formdata 的默认处理
                //XMLHttpRequest会对 formdata 进行正确的处理
                processData: false,

                success: function (data) {
                    if (data.status == "true") {
                        alert("上传成功！");
                    }
                    if (data.status == "error") {
                        alert(data.msg);
                    }
                },
                error: function () {
                    alert("上传失败！");
                }
            });
        });
    });

    function toDevice() {
        window.history.back(-1);
    }
</script>
</body>
</html>
